package net.sureon.web.user;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sureon.app.UserSession;
import net.sureon.biz.DailyTimingMgr;
import net.sureon.biz.UserMgr;
import net.sureon.dao.DailyTiming;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/**
 * 审核申请类
 * 
 * @author Administrator
 * 
 */
public class ConfirmDailyTiming implements Controller {
	private DailyTimingMgr dailyTimingMgr;
	private UserMgr userMgr;

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		DailyTiming dt = null;
		// 当前用户ID也即批准人ID
		long userID = ((net.sureon.app.UserSession) request.getSession()
				.getAttribute(UserSession.HTTP_SESSION_KEY)).getUserID();
		long companyID = ((net.sureon.app.UserSession) request.getSession()
				.getAttribute(UserSession.HTTP_SESSION_KEY)).getCompanyID();

		long dailyTimingID = Long.parseLong(request
				.getParameter("dailyTimingID"));
		
		String reviewNote = new String(request.getParameter("reviewNote").getBytes("ISO-8859-1"), "utf-8");
		if(reviewNote == null || "".equals(reviewNote)) {
			reviewNote = "";
		}

		dailyTimingMgr.updateDailyTiming(companyID, dailyTimingID, new java.util.Date(),
				userID, reviewNote, "Approved");

		 response.sendRedirect(request.getContextPath()
		 + "/user/underlingDailyTiming.do");
		return null;
	}

	public DailyTimingMgr getDailyTimingMgr() {
		return dailyTimingMgr;
	}

	public void setDailyTimingMgr(DailyTimingMgr dailyTimingMgr) {
		this.dailyTimingMgr = dailyTimingMgr;
	}

	public UserMgr getUserMgr() {
		return userMgr;
	}

	public void setUserMgr(UserMgr userMgr) {
		this.userMgr = userMgr;
	}

}
